from django.db import models

# Create your models here.
class Family(models.Model) :

  TYPE_CHOICE = (
	('M', u'xxx'),
	('F', u'yyy'),
	('G', u'zzz')
  )
  
  id = models.AutoField(primary_key=True)
  name = models.CharField(max_length=30)
  description = models.TextField(max_length=50)
  type = models.CharField(choices=TYPE_CHOICE,max_length=50)
  
  def __unicode__(self):
  	return self.name;
  
  
class Species(models.Model) :
  id = models.AutoField(primary_key=True)
  name = models.CharField(max_length=30)
  picture = models.ImageField(upload_to='/tmp')
  price = models.FloatField( )
  color = models.CharField(max_length=20)
  description = models.TextField(max_length=50)
  family = models.ForeignKey(Family)

  def __unicode__(self):
  	return self.name;
 
class Member(models.Model) :
  id = models.CharField(primary_key=True, max_length=50)
  name = models.CharField(max_length=50)
  username = models.CharField(max_length=50)
  password = models.CharField(max_length=50)
  #telephone = models.PhoneNumberField()
  telephone = models.CharField(max_length=50)
  email = models.EmailField()

  def __unicode__(self):
  	return self.name
  
class Garden(models.Model) :
  id = models.AutoField(primary_key=True)
  name = models.CharField(max_length=50)
  picture = models.ImageField(upload_to='/tmp')
  g_long = models.IntegerField()
  g_with = models.IntegerField()
  description = models.TextField(max_length=50)
  member = models.ForeignKey(Member)

  def __unicode__(self):
  	return self.name

  
class Composition(models.Model) :
  id = models.AutoField(primary_key=True)
  species = models.ForeignKey(Species)
  amount = models.IntegerField()
  garden = models.ForeignKey(Garden)

  def __unicode__(self):
  	return self.name + ' ' + self.amount


  
  
class Order(models.Model) :
  PSTATUS_CHOICE = (
	('A', 'AAA'),
	('B', 'BBB'),
	('C', 'CCC')
  )
  PMETHOD_CHOICE = (
	('A', 'AAA'),
	('B', 'BBB'),
	('C', 'CCC')
  )
  
  id = models.AutoField(primary_key=True)
  date = models.DateField(auto_now=True)
  price = models.FloatField()
  
  payment_status = models.CharField(choices = PSTATUS_CHOICE, max_length=50)
  payment_method = models.CharField(choices = PMETHOD_CHOICE, max_length=50)
  
  status = models.CharField(max_length=50)
  member = models.ForeignKey(Member)

  def __unicode__(self):
  	return self.member

 
